'use strict';

const Controller = require('egg').Controller;

class ShopController extends Controller {
  async index() {
    const { ctx } = this;
    const result = await ctx.curl('https://registry.npm.taobao.org/egg/latest', {
      // 自动解析 JSON response
      dataType: 'json',
      // 3 秒超时
      timeout: 3000,
    });

    ctx.body = {
      status: result.status,
      headers: result.headers,
      package: result.data,
    };
  }
}

module.exports = ShopController;
